# 购物车代码
```python
product_list=[('Ovaltine',4),
              ('Vita',3),
              ('lemon tea',3),
              ('book',100),
              ("AG",600),
              ('Computer',6000),
              ('glass',300),
              ('phone',6000)]
shopping_car=[]
balance =input('请输入支付宝余额')                 
while True:
    balance=int(balance)
    for item in product_list:
        print(product_list.index(item),item)
    choice=input('请输入产品编号')
    if choice.isdigit():
        choice=int(choice)
        if choice >=0 and choice<8:
            if balance>=product_list[choice][1]:
                balance=balance-product_list[choice][1]
                shopping_car.append(product_list[choice][0])
                print("你把商品%s添加到购物车支付宝余额是%s"%(product_list[choice][0],balance))
                print(shopping_car)
                print(''默认继续购买,若不想购买请按按q键退出'')
            else:
                print('你的余额不足,请重新选择商品')             
                print('或者请按Q退出')
        else:
            print('商品里没有这个列表，请重新选择一个商品')
    elif choice =='q':
        print('-----购物车清单----')
        for item in shopping_car:
            print(item)
        print('你的支付宝余额为%s元'%balance)
        print('以购买{}'.format(shopping_car))
        break
    else:
        print('请输入对应编码')

